import java.util.Arrays;

public class test3 {
    public static void main(String[] args) {
        System.out.println(myReverse("hi hhh world"));
        StringBuilder sb = new StringBuilder("hi hhh world");
        System.out.println(sb.reverse());
        String str = "hi hhh world";
        StringBuffer
    }

    private static String myReverse(String str) {
        char[] chars = str.toCharArray();
        int left = 0,right = str.length()-1;
        while(left<right){
            swap(chars,left++,right--);
        }
        return new String(chars);
    }

    private static void swap(char[] chars, int left, int right) {

        char tmp = chars[left];
        chars[left] = chars[right];
        chars[right] = tmp;
    }


}
